<template>
  <div>
  </div>
</template>

<script lang='ts'>
import { Component, Vue } from 'vue-property-decorator'
import { getApiDoc } from '@/api/system'
import { SearchType } from '@/models/searchParams'
// import { indexOf, keys } from 'lodash'

@Component({})
export default class Page extends Vue {
  mounted() {
    this.getApiDoc()
  }

  async getApiDoc() {
    const resp: any = await getApiDoc('order')
    console.log(resp.paths)
    const json:any = resp.paths['/order/listMyOrders'].get.parameters
    const searchParams = Object.keys(json).map(key => {
      return {
        label: json[key].description,
        key: json[key].name,
        type: SearchType.Input,
        value: '',
        placeholder: `请输入${json[key].description}`
      }
    })
    console.log(JSON.stringify(searchParams))

    const column:any = resp.definitions.OrderVo.properties
    console.log(column)
    const columnList:any = Object.keys(column).map(key => {
      let label
      const desc:string = column[key].description
      if (desc.indexOf('(') > 0) {
        const desc:string = column[key].description
        label = desc.substring(0, desc.indexOf('('))
      } else {
        label = column[key].description
      }
      return {
        prop: key,
        label: label,
        minWidth: 100
      }
    })
    console.log(JSON.stringify(columnList))
  }
}
</script>

<style lang='scss'>

</style>
